package com.atguigu.lease.common.exception;

import com.atguigu.lease.common.result.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * ClassName:ExceptionAdvice
 * Package: com.atguigu.lease.common.exception
 * Description:
 *
 * @Author Makabaka
 * @Create 2024/9/23 16:46
 * @Version 1.0
 */
@RestControllerAdvice
public class ExceptionAdvice {

    @ExceptionHandler(Exception.class)
    public Result error(Exception e){
        e.printStackTrace();
        return Result.fail();
    }

//    捕获自定义异常  删除公寓异常
    @ExceptionHandler(LeaseException.class)
    public Result error(LeaseException le){
        return Result.build(null,le.getResultCodeEnum());
    }

}
